<?php
App::uses('AppModel', 'Model');
/**
 * Employee Model
 *
 * @property EmpJoblvl $JobLvl
 * @property EmpJobstatus $JobStatus
 * @property EmpJobtype $jobType
 */
class Employee extends AppModel {

/**
 * Primary key field
 *
 * @var string
 */
	public $primaryKey = 'e_id';
/**
 * Display field
 *
 * @var string
 */
	public $displayField = 'e_fname';


	
	
	//VALIDATION
	
	public $validate = array(
			'e_fname' => array(
			// VALIDATION CHECKING IF LETTERS & NUMBERS ONLY
				'alphaNumeric' => array(
					'rule'     => 'alphaNumeric',
					'message'  => 'Alphabets only'
				),
			//VALIDATION CHECKING IF FIELD IS EMPTY
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Field can not be empty'
				)
			),
			'e_lname' => array(
				'alphaNumeric' => array(
					'rule'     => 'alphaNumeric',
					'message'  => 'Alphabets only'
				),
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Field can not be empty'
				)
				
			),
			'e_homephone' => array(
				'number' => array(
					'rule' => 'numeric',
					'message' => 'Please enter numbers only'
				),
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Field can not be empty'
				),
				//VALIDATION FOR LENGTH MUST BE 10 CHARACTERS
				'length' => array( 
					'rule' => array('between', 10, 10),
					'message' => 'Home Phone Number Must be 10 characters long' 
				)
			),
			'e_mobilephone' => array(
				'number' => array(
					'rule' => 'numeric',
					'message' => 'Please enter numbers only'
				),
				'notEmpty' => array(
					'rule' => 'notEmpty',
					'message'  => 'Field can not be empty'
				),
				//VALIDATION FOR LENGTH MUST BE 10 CHARACTERS
				'length' => array( 
					'rule' => array('between', 10, 10),
					'message' => 'Phone Number Must be 10 characters long' 
				)
			),
			'e_email' => array(
				'email' => array(
				'rule'    => array('email', true),
				'message' => 'Please supply a valid email address.'
				)
			)
		);
			
	
	//The Associations below have been created with all possible keys, those that are not needed can be removed

/**
 * belongsTo associations
 *
 * @var array
 */

	public $hasMany = array(
		'Interaction' => array(
			'className' => 'Interaction',
			'foreignKey' => 'e_id'
		),
		'EmployeeJobLvl' => array(
			'className' => 'EmployeeJobLvl',
			'foreignKey' => 'emp_joblvl_employee',
		),
		'EmployeeJobStatus' => array(
			'className' => 'EmployeeJobStatus',
			'foreignKey' => 'emp_jobstatus_employee',
		),
		'EmployeeJobType' => array(
			'className' => 'EmployeeJobType',
			'foreignKey' => 'emp_jobtype_employee',
		)
	);
}
